library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;


entity booth_mux is
generic (N : integer := 16);
  port( M0   : in  std_logic_vector (N-1 downto 0);
        M1   : in  std_logic_vector (N-1 downto 0);
        M2   : in  std_logic_vector (N-1 downto 0);
        M3   : in  std_logic_vector (N-1 downto 0);
        M4   : in  std_logic_vector (N-1 downto 0);
        SEL  : in  std_logic_vector (2 downto 0);
        MOUT : out std_logic_vector (N-1 downto 0)
        );
end booth_mux;

architecture Behavioral of booth_mux is
begin

  main : process (M0, M1, M2, M3, M4, SEL)
  begin  -- process main
    case SEL is
      when "000"|"111"  =>
        MOUT <= M0;
      when "001"|"010"  =>
        MOUT <= M1;
      when "011"        =>
        MOUT <= M3;
      when "100"        =>
        MOUT <= M4;
      when "101"|"110"  =>
        MOUT <= M2;
      when others       =>
        MOUT <= (others => '0');
    end case;
  end process main;
end Behavioral;
